package net.zoneland.zrdp.biz.domain.pojo.form;

import lombok.Data;
import lombok.experimental.Accessors;
import net.zoneland.zrdp.biz.validator.TaskProcessFormGroup;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Size;
import javax.validation.groups.Default;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 任务处理参数对象.
 *
 * @version v1.0
 */
@Accessors(chain = true)
@Data
public class TaskProcessForm implements Serializable {

    private static final long serialVersionUID = 5674786169569872589L;

    // 最大长度提示.
    private static final String LENGTH_MESSAGE = "：不能超过1000字";
    // list最大长度提示.
    private static final String SIZE_MESSAGE = "：不能超过50个处理人";
    // 不能为空提示.
    private static final String NOT_BLANK_MESSAGE = "：不能为空";

    private static final String PIID_MESSAGE = "流程编号";
    private static final String TIID_MESSAGE = "任务编码";
    private static final String APPLY_ID_MESSAGE = "工单号";
    private static final String APPLY_NAME_MESSAGE = "工单标题";
    private static final String SYS_NODE_NAME_MESSAGE = "当前节点名称";
    private static final String SYS_NODE_ID_MESSAGE = "当前节点编码";
    private static final String NEXT_NODE_MESSAGE = "下一环节";
    private static final String NEXT_NODE_NAME_MESSAGE = "下一环节名称";
    private static final String OPTION_MESSAGE = "决策名称";
    private static final String HANDLERS_MESSAGE = "下一环节处理人";

    /** 业务流程编码. **/
    private String businessProcess;

    /** 流程编号. **/
    @Length(max = 1000, message = PIID_MESSAGE + LENGTH_MESSAGE)
    @NotBlank(message = PIID_MESSAGE + NOT_BLANK_MESSAGE, groups = {TaskProcessFormGroup.ReliveProcess.class,
        TaskProcessFormGroup.GetTiidList.class, Default.class})
    private String piid;

    /** 任务编码. **/
    @Length(max = 1000, message = TIID_MESSAGE + LENGTH_MESSAGE)
    @NotBlank(message = TIID_MESSAGE + NOT_BLANK_MESSAGE)
    private String tiid;

    /** 任务编码（用于获取审批记录）. **/
    private List<String> tiidList;

    /** 工单号. **/
    @Length(max = 1000, message = APPLY_ID_MESSAGE + LENGTH_MESSAGE)
    @NotBlank(message = APPLY_ID_MESSAGE + NOT_BLANK_MESSAGE)
    private String applyId;

    /** 工单标题. **/
    @Length(max = 1000, message = APPLY_NAME_MESSAGE + LENGTH_MESSAGE)
    @NotBlank(message = APPLY_NAME_MESSAGE + NOT_BLANK_MESSAGE)
    private String applyTitle;

    /** 任务标记. **/
    @Length(max = 1000, message = "任务标记" + LENGTH_MESSAGE)
    private String taskTag;

    /** 任务标记（用于获取审批记录）. **/
    private List<String> taskTagList;

    /** 当前节点名称. **/
    @Length(max = 1000, message = SYS_NODE_NAME_MESSAGE + LENGTH_MESSAGE)
    @NotBlank(message = SYS_NODE_NAME_MESSAGE + NOT_BLANK_MESSAGE)
    private String sysNodeName;

    /** 当前节点编码. **/
    @Length(max = 1000, message = SYS_NODE_ID_MESSAGE + LENGTH_MESSAGE)
    @NotBlank(message = SYS_NODE_ID_MESSAGE + NOT_BLANK_MESSAGE, groups = {TaskProcessFormGroup.ReliveProcess.class,
        TaskProcessFormGroup.GetTiidList.class, Default.class})
    private String sysNodeId;

    /** 下一环节. **/
    @Length(max = 1000, message = NEXT_NODE_MESSAGE + LENGTH_MESSAGE)
    @NotBlank(message = NEXT_NODE_MESSAGE + NOT_BLANK_MESSAGE)
    private String nextNode;

    /** 下一环节名称. **/
    @Length(max = 1000, message = NEXT_NODE_NAME_MESSAGE + LENGTH_MESSAGE)
    @NotBlank(message = NEXT_NODE_NAME_MESSAGE + NOT_BLANK_MESSAGE)
    private String nextNodeName;

    /** 决策选项. **/
    @NotBlank(message = "决策选项" + NOT_BLANK_MESSAGE,
        groups = TaskProcessFormGroup.DecisionGroup.class)
    private String decision;

    /** 决策名称. **/
    @Length(max = 1000, message = OPTION_MESSAGE + LENGTH_MESSAGE)
    @NotBlank(message = OPTION_MESSAGE + NOT_BLANK_MESSAGE,
        groups = {TaskProcessFormGroup.ReliveProcess.class, Default.class})
    private String option;

    /** 审批意见. **/
    @Length(max = 1000, message = "审批意见" + LENGTH_MESSAGE)
    private String notion;

    /** 待办的处理人. **/
    @Valid
    @NotEmpty(message = "待办的处理人" + NOT_BLANK_MESSAGE,
        groups = TaskProcessFormGroup.ReliveProcess.class)
    private UserInfoForm owner;

    /** 下一环节处理人. **/
    @Valid
    @Size(max = 50, message = HANDLERS_MESSAGE + SIZE_MESSAGE)
    @NotEmpty(message = HANDLERS_MESSAGE + NOT_BLANK_MESSAGE)
    private List<UserInfoForm> handlers;

    /** 创建时间. **/
    private LocalDateTime createTime;

    /** 修改时间. **/
    private LocalDateTime modifyTime;

    /** 扩展参数. **/
    private Map<String, String> extendData;

    /** 下一任务扩展参数. **/
    private Map<String, String> nextTaskExtData;

    /** 是否挂起任务 **/
    private Boolean suspendTask = Boolean.FALSE;
}
